import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.key_yellow = pygame.image.load("../资源/图片/黄钥匙.jpg").convert_alpha()
        self.key_blue = pygame.image.load("../资源/图片/蓝钥匙.jpg").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.door_red = pygame.image.load("../资源/图片/红门.jpg").convert_alpha()
        self.door_iron = pygame.image.load("../资源/图片/铁门.png").convert_alpha()
        self.hp_red = pygame.image.load("../资源/图片/红药.jpg").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.cross = pygame.image.load("../资源/图片/十字架.png").convert_alpha()
        self.kulou_leader = pygame.image.load("../资源/图片/骷髅队长.png").convert_alpha()
        self.red_bat = pygame.image.load("../资源/图片/红蝙蝠.png").convert_alpha()
        self.white_warrior = pygame.image.load("../资源/图片/白衣武士.png").convert_alpha()

        self.hero_pos = (5, 10)
        self.up_pos = (0, 0)
        self.down_pos = (4, 10)
        self.variable_pos = {
            (3, 10): (self.door_yellow, '黄门'),
            (7, 10): (self.door_yellow, '黄门'),
            (5, 1): (self.door_blue, '蓝门'),
            (5, 7): (self.door_blue, '蓝门'),
            (2, 4): (self.door_blue, '蓝门'),
            (8, 4): (self.door_blue, '蓝门'),
            (5, 9): (self.door_red, '红门'),
            (4, 4): (self.door_iron, '铁门'),
            (5, 5): (self.door_iron, '墙'),
            (5, 3): (self.door_iron, '墙'),
            (6, 4): (self.door_iron, '墙'),
            (2, 7): (self.key_yellow, '黄钥匙'),
            (8, 7): (self.key_yellow, '黄钥匙'),
            (3, 8): (self.key_blue, '蓝钥匙'),
            (4, 8): (self.key_blue, '蓝钥匙'),
            (6, 8): (self.key_blue, '蓝钥匙'),
            (7, 8): (self.key_blue, '蓝钥匙'),
            (2, 6): (self.hp_red, '红药'),
            (3, 7): (self.hp_red, '红药'),
            (7, 7): (self.hp_red, '红药'),
            (8, 6): (self.hp_red, '红药'),
            (5, 8): (self.hp_blue, '蓝药'),
            (3, 2): (self.gem_blue, '蓝宝石'),
            (7, 6): (self.gem_blue, '蓝宝石'),
            (7, 2): (self.gem_red, '红宝石'),
            (3, 6): (self.gem_red, '红宝石'),
            (5, 4): (self.cross, '十字架'),
            (7, 1): (self.kulou_leader, '骷髅队长'),
            (8, 2): (self.kulou_leader, '骷髅队长'),
            (2, 2): (self.red_bat, '红蝙蝠'),
            (3, 1): (self.red_bat, '红蝙蝠'),
            (5, 2): (self.white_warrior, '白衣武士'),
            (5, 6): (self.white_warrior, '白衣武士'),
            (3, 4): (self.white_warrior, '白衣武士'),
            (7, 4): (self.white_warrior, '白衣武士'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in [(0, 1), (0, 2), (1, 1), (0, 10), (10, 10), (10, 0), (10, 1), (10, 2), (9, 0), (9, 1), (8, 0), (4, 1),
                  (4, 2), (4, 3), (3, 3), (2, 3), (6, 1), (6, 2), (6, 3), (7, 3), (8, 3), (1, 5), (1, 6), (1, 7), (1, 8),
                  (2, 8), (2, 9), (3, 9), (4, 9), (4, 7), (4, 6), (4, 5), (3, 5), (2, 5), (6, 5), (6, 6), (6, 7), (6, 9),
                  (7, 9), (8, 9), (8, 8), (9, 8), (9, 7), (9, 6), (9, 5), (8, 5), (7, 5)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
